package redis

import (
	"context"
	"fmt"
)

const GoodsStockPrefix = "goods_stock:goods_id_"

func SyncGoodsStock(goodsId int64, stock int64) {
	key := GoodsStockPrefix + fmt.Sprintf("%d", goodsId)
	for i := 0; i < int(stock); i++ {
		Rdb.LPush(context.Background(), key)
	}
}
func GetGoodsStock(goodsId int64) int64 {
	key := GoodsStockPrefix + fmt.Sprintf("%d", goodsId)
	return Rdb.LLen(context.Background(), key).Val()
}
